package Code.Test6;

public class GirlFrendTest {
    public static void main(String[] args) {

        GirlFriend[] arr = new GirlFriend[4];

        GirlFriend g1 = new GirlFriend("小红", 18, '女', "打游戏");
        GirlFriend g2 = new GirlFriend("小黄", 19, '女', "游泳");
        GirlFriend g3 = new GirlFriend("小绿", 20, '女', "旅游");
        GirlFriend g4 = new GirlFriend("小花", 21, '女', "运动");

        arr[0] = g1;
        arr[1] = g2;
        arr[2] = g3;
        arr[3] = g4;

        int ageSUm = 0;
        for (int i = 0; i < arr.length; i++) {
            ageSUm += arr[i].getAge();
        }
        int avg = ageSUm/ arr.length;
        System.out.println("平均年龄为："+avg);

        int count= 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i].getAge()<avg){
                count++;
                System.out.println("姓名："+arr[i].getName()+",年龄："+arr[i].getAge()+
                        ",性别："+arr[i].getGender()+",爱好："+arr[i].getHobby());
            }
        }
        System.out.println("比平均年龄地的有"+count+"个");
    }
}
